package com.qf.compusdemo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.compusdemo.dao.UserDao;
import com.qf.compusdemo.entity.User;
import com.qf.compusdemo.service.UserService;
import com.qf.compusdemo.vo.Ppage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public IPage<User> getAllUser(Page page, User user) {
        QueryWrapper<User> wrapper=new QueryWrapper<>();

        if(user.getUsername()!=null){
            wrapper.like("username",user.getUsername());
        }

        IPage<User> ipage=userDao.selectPage(page,wrapper);
        return ipage;

    }

    @Override
    public int delUser(List lists){
        return userDao.deleteBatchIds(lists);
    }

    @Override
    public int updateUser(User uu) {
        return userDao.updateUser(uu);
    }

    @Override
    public int adds(User user) {
        return userDao.insertUser(user);
    }


}
